| Coding Forum Collaborate, receive help, or discuss coding related issues. |
![]() | | Tweet | |
| | #1 | ||
![]() | Help Understanding This Code however, i cannot read it correctly as what its doing. i am an ok TS programmer. i have my own indictor that i am working on. i want to integrate the following code so that it only draws the buy or sell lines when i am long or short. right now it works completly independent of my code. please help! {Type : Indicator, Name : Variable Volatility Stops} INPUT: LENGTH (21), CONST(3.05); vaR: SWITCH(1), TR(0), ARC(0), SAR(0),HISIC(0),LOSIC(0); TR= VOLATILITY (LENGTH); ARC= TR* CONST; IF CURRENTbar = length then begin hisic=c; losic=c; if h>= xaverage (h,length-1) [1] then begin hisic= highest(c,length); Sar=hisic-arc; switch= 1; end; if l <= xaverage (l,length-1) [1] then begin losic= lowest (c,length); sar = losic +arc; switch=0; end; end; if switch =1 then begin if c>hisic then hisic=c; sar=hisic - arc; if c< sar then begin switch=0; losic=c; sar = losic + arc; end; end; if switch=0 then begin if c< losic then losic=c; sar= losic +arc; if c> sar then begin switch=1; hisic=c; saR=HISIC- ARC; END; END; IF C > SAR { AND C[1] < SAR } THEN Plot1(SAR,"Sell"); IF C < SAR { AND C[1] > SAR} THEN Plot2(sar,"Buy"); | ||
| |
|
| | #2 | ||
![]() | Re: Help Understanding This Code | ||
| |
|
| | #3 | ||
![]() | Re: Help Understanding This Code | ||
| |
|
| | #4 | ||
![]() | Re: Help Understanding This Code | ||
| |
|
| The Following User Says Thank You to Tams For This Useful Post: | ||
ephi144 (04-10-2009) | ||
| | #5 | ||
![]() | Re: Help Understanding This Code I_MarketPosition can only be used in a study. I_MarketPosition will only return a value if a strategy is applied to the same data. ![]() Code: inputs:
ATRLength( 10 ) ,
NumATRs( 3 ) ;
variables:
ATRCalc( 0 ),
MP( 0 ),
PosHigh( 0 ),
PosLow( 0 ) ;
ATRCalc = AvgTrueRange( ATRLength ) * NumATRs ;
MP = I_MarketPosition ;
if MP > 0 then
begin
if MP[1] <> 1 or High > PosHigh then
PosHigh = High ;
Plot1( PosHigh - ATRCalc, "Plot1" ) ;
end
else
if MP < 0 then
begin
if MP[1] <> -1 or Low < PosLow then
PosLow = Low ;
Plot2 (PosLow + ATRCalc, "Plot2");
end ; | ||
| |
|
| The Following User Says Thank You to thrunner For This Useful Post: | ||
ephi144 (04-10-2009) | ||
| | #6 | ||
![]() | Re: Help Understanding This Code thank you for helping me. i just wanted to know what the heck the code was doing. i wanted the sar to paint based on my position. if u use the code as an indicator you will see that the it switches to long or short whenever the price closes above the SAR value. which did not play well within my code. i think i have it figured out. as well as therunners help is making much more sense now. i will try to integrate your code within my strategy today. however, i have made the following changes. please let me know if the following looks ok to make sure i was understanding the code correctly. TR= VOLATILITY (VOL_LENGTH); ARC= TR * VOL_CONST; IF CURRENTbar = length then begin HISIC = close; LOSIC = close; if high >= xaverage (high,VOL_LENGTH-1) [1] then begin HISIC = highest(close,VOL_LENGTH) ; SAR = HISIC-arc; SWITCH_IT= 1; end; if low <= xaverage (low,VOL_LENGTH-1) [1] then begin LOSIC = lowest (close,VOL_LENGTH); SAR = LOSIC + ARC; SWITCH_IT=0; end; end; if SWITCH_IT = 1 then begin if close >hisic then hisic = close; SAR = hisic - arc; if close < SAR and AreWeShort = true then begin SWITCH_IT = 0; LOSIC = close; SAR = LOSIC + ARC; end; end; if SWITCH_IT=0 then begin if close < losic then losic = close; SAR = losic +arc; if close > SAR and AreWeLong = true then begin SWITCH_IT = 1; HISIC = close; SAR = HISIC- ARC; END; END; | ||
| |
|
![]() |
| Thread Tools | |
| Display Modes | Help Others By Rating This Thread |
| |
| ∧ Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help with Understanding Put Options | januson | Beginners Forum | 5 | 10-02-2008 11:18 PM |
| Help understanding the Tape. | Yigal | E-mini Futures Trading Laboratory | 16 | 04-11-2007 11:55 PM |
| [Understanding the TICK] | Soultrader | Trading Videos | 14 | 03-12-2007 12:29 AM |
| Understanding the TICK | Soultrader | Market Internals | 3 | 08-20-2006 06:55 PM |
| [Understanding the TRIN] by The Lab | Soultrader | Trading Videos | 0 | 08-07-2006 02:05 AM |