- Topics: 6
- Replies: 13
- Posts: 19
Here’s the whole thing. It’s a lashup in early stage of exploration. Note that there’s no carriage returns/line feeds anywhere, so Ctrl-C, Ctrl-V makes a mess.
// create all the change components DPco = open() – close(OFFSET=1); DPoc = close() – open(); DPhh = high() – high(OFFSET=1); DPll = low() – low(OFFSET=1); DPhl = (high() – low()) * ( ((close() – low()) / (high() – low())) – 0.5); // create the total change DPtot = DPco + DPoc + DPhh + DPll + DPhl; // compute the change compared to previous bar D2P = DPtot – OFFSET(DPtot, OFFSET=1); //c1 = (DPtot > 0) and (D2P > 0) and (OFFSET(D2P, OFFSET=1) > 0) //c2 = (DPtot <= 0) ; //TRADING = SWITCH( c1 , c2 ); TRADING = SWITCH( (DPtot > 0) and (D2P > 0) and (OFFSET(D2P, OFFSET=1) > 0), (DPtot <= 0) ); BUYPRICE = IF( TRADING, (IF(OFFSET(TRADING, OFFSET=1) , BUYPRICE, ( (close() + open() + high() + low())/4.0) ) ), 0); SELLPRICE = IF( TRADING, 0, (IF(OFFSET(TRADING, OFFSET=1), ( (close() + open() + high() + low())/4.0 ), 0) )); //THISPROFIT = IF( TRADING, 0, (IF(OFFSET(TRADING, OFFSET=1), (SELLPRICE – BUYPRICE), 0) )); TOTPROFIT = OFFSET(TOTPROFIT, OFFSET=1) + THISPROFIT; //Plots plot1 = DPtot; plot1.Plotstyle = step; plot1.colour = green; plot1.visible = 1; plot2 = D2P; plot2.Plotstyle = histogram; plot2.colour = red; plot3 = TRADING; plot3.Plotstyle = step; plot3.colour = black; plot3.linewidth = 2; plot3.visible = 1; plot4 = BUYPRICE; plot4.Plotstyle = step; plot4.visible = 1; plot5 = THISPROFIT; plot5.Plotstyle = step; plot5.linewidth = 2; plot5.visible = 1; plot6 = SELLPRICE; plot6.Plotstyle = step; plot6.linewidth = 2; plot6.visible = 1; plot7 = TOTPROFIT; plot7.Plotstyle = step; plot7.linewidth = 2; plot7.visible = 1;
I had a look for dodgy characters in Notepad … nothing except a blank after one of the semi-colon terminators. It made no difference.
Note that I’ve made 2 posts and on reflection I think the two problems are possibly symptoms of the same problem: something to do with putting the OFFSET inside an IF() (maybe?).
I’m very interested in getting this running!