November 14, 2021 at 6:49 pm #66601
I am trying to code both breadth conditions for risk on and risk off as per below article but i think my code is not correct. Can you please help.123456789v1 = GETDATA(CODE=STOCKS ABOVE 50 MA -NF 50 :Market Breadth);v2 = v1<65;v3 = CLOSE() < (HIGHESTHIGH(BARS=252) - (0.25/100) * HIGHESTHIGH(BARS=252));v4 = v2 and v3;v5 = TIMESINCESIGNAL(v4) < 10;v6 = v1 CrossesBelow 50;v5 and v6November 15, 2021 at 11:16 am #66612
Are you applying the script to the SPX directly? If not, V3 needs to use a GETDATA() for the SPX index as well. I’d also use the WithinRange() function to work out if the close is within the zone it needs to be. Here it is in isolation…12345D1 = GETDATA(CODE=SPX:WI) ;D2 = HIGHESTHIGH(D1, BACKTYPE=Bars, BARS=256);WITHINRANGE(D1,D2, PERCENT=0.25)
If adjusting the script to use the above does not fix the issue you are seeing please provide more information on what the problem is.November 16, 2021 at 3:05 am #66647
I think my code for below condition is not correct. Yes i am directly applying to nifty rather than spx.
Condition 3: If Condition 1 & 2, start a days since true count#
Condition 4: If days since true count <= ten days and the percentage of S&P 500 members crosses below 50%, signal risk-off
Condition 5: If percentage of members crosses above 66%, reset condition = true
DeepakNovember 21, 2021 at 5:00 pm #66683
Can you find error if possible.
DeepakNovember 22, 2021 at 3:32 pm #66706
You’ll need to provide more information, I am not sure what isn’t working based on what you’ve posted so far, and the source you have is for SPX not NIFTY, meaning there would be custom bread codes being used as well? Include all the scripts you’re using to build any custom breadth codes, and a screen shot of where your final script is showing an incorrect result.November 23, 2021 at 2:48 am #66707
When i applied below formula to spx it didnot match with number of signals as said in the article. Please see attached pic. Let me pose my question differently how u would have coded it for spx.123456789v1 = GETDATA(CODE=S5FI:BM);v2 = v1<65;v3 = CLOSE() < (HIGHESTHIGH(BARS=252) - (0.25/100) * HIGHESTHIGH(BARS=252));v4 = v2 and v3;v5 = TIMESINCESIGNAL(v4) < 10;v6 = v1 CrossesBelow 50;v5 and v6November 24, 2021 at 1:01 pm #66716
I would code the 5 conditions (for the first set of rules) this way:12345678910111213141516171819202122//Get Breadth DataV1 = GETDATA(CODE=MKTBRSG1:Market Breadth);//Get Index DataV2 = GETDATA(CODE=SPX:WI) ;//Find Index Highest High over last 252 BarsV3 = HIGHESTHIGH(V2, BARS=252) ;//Condition 1COND1 = V1 <= 65;//Condition 2COND2 = WITHINRANGE(V2,V3, PERCENT=0.25) ;//Is Condition 1 and 2 TrueV4 = COND1 and COND2 ;//Condition 3COND3 = TIMESINCESIGNAL(V4) ;//Condition 4COND4 = COND3 <= 10 and V1 CrossesBelow 50 ;//Condition 5COND5 = V1 CrossesAbove 66 ;//Switch Between Cond 4 and Cond 5SWITCH(COND4,COND5)November 25, 2021 at 12:50 am #66727Thomas
- Topics: 130
- Replies: 176
- Posts: 306
Thank you Matthew,
I was also very interested in this topic/script.
- You must be logged in to reply to this topic.