Reply To: Mysterious 'valid script' violation

Optuma Forums Optuma Scripting Mysterious 'valid script' violation Reply To: Mysterious 'valid script' violation

#46683

Colin
  • Topics: 4
  • Replies: 6
  • Posts: 10

Thanks Mathew,

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! 

cheers

colin

 

 

Cheers

colin

 

Pin It on Pinterest

Share This

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close