Hi
Here is a your code.
You was lucky boy today. I count not sleep and I try to code it for fun.
The only that you need to correct is the ROC in $ points all the rest I 
bereave are ok.
I really don’t remember how to make  Roc  in $ but if you search in the 
mailing list  you will find how

All the best
Panos

//////// start ///////////////
// Translated  by Panos Boufardeas 03-SEP-2010
// http://www.equis.com/customer/resources/formulas/formula.aspx?Id=27
// http://www.precisiontradingsystems.com/INSYNC.htm

BOLInSLB = MA( C ,20 ) - 2 * ( StDev( C ,20 ) ) ;
BOLInSUB = MA( C ,20 ) + 2 * ( StDev( C ,20 ) ) ;
BOLInS2 = C - BOLInSLB  / (BOLInSUB  - BOLInSUB ) ;
BOLInSLL = IIf( BOLInS2 < .05 ,-5 ,IIf( BOLInS2  > .95 ,5 ,0 ) ) ;

CCIInS = IIf( CCI(14 ) > 100 ,5 ,IIf ( CCI(14 ) < -100 ,-5 ,0 ) );

// EMV - Ease of Movement
// 
http://support2.dundas.com/OnlineDocumentation/WinChart2003/EaseOfMovement.html 

// Calculation The Ease of Movement should be accompanied with it's 
exponential moving average.
EMVcalc = ( (H+L/2) - ( Ref(H,-1) + Ref(L,-1) ) /2 ) / (V / H-L) ;
EMV= EMA(EMVcalc,10 );
EMVInS2 = EMV - MA( EMV ,10 ) ;
EMVInSB =IIf( EMVInS2  < 0 ,IIf( MA( EMV,10  ) < 0 ,-5 ,0 ) ,0 ) ;
EMVInSS = IIf( EMVInS2> 0 ,IIf( MA( EMV ,10  ) > 0 ,5 ,0 ) ,0 ) ;

// Macd
MACDInS2 =MACD(12,25 ) - MA( MACD(12,25 ) ,9  );
MACDinSB =IIf( MACDInS2  < 0, IIf( MA( MACD( ) ,10 ) < 0 ,-5 ,0 ) ,0 );
MACDInSS = IIf(MACDInS2  > 0 ,IIf( MA( MACD( ) ,10 ) > 0 ,5 ,0 ) ,0 );

// Money Flow index.
MFIInS =IIf( MFI( 20 ) > 80 ,5 , IIf( MFI( 20 ) < 20 ,-5 ,0 ) );

// PDO - Detrended Price Oscillator
PDO= C-Ref(MA(C,18),-(18/2)+1);   // PDO modify
PDOInS2 =PDO - MA( PDO ,10 );
PDOInSB = IIf( PDOInS2 < 0 ,IIf( MA( PDO ,10 ) <0 ,-5 ,0 ) ,0 );
PDOInSS =IIf( PDOInS2 > 0 ,IIf( MA( PDO ,10 ) > 0 ,5 ,0 ) ,0 );

// ROC in points
// ROCInS2 = ROC( C ,10 ,$ ) - Mov( ROC( C ,10 ,$ ) ,10 ,S )
ROCInS2 = ROC( C ,10  ) - MA( ROC( C ,10  ) ,10  );   //<< need to correct
//ROCInSB = IIf( ROCInS2 < 0 ,IIf( MA( ROC( C ,10 ,$ ) ,10 ) < 0 ,-5 ,0 ) ,0 )
ROCInSB = IIf( ROCInS2 < 0 ,IIf( MA( ROC( C ,10  ) ,10 ) < 0 ,-5 ,0 ) ,0 );
// ROCInSS Index =  IIf( ROCInS2 > 0 ,IIf( MA( ROC( C ,10 ,$ ) ,10 ) > 0 ,5 
,0 ) ,0 )
ROCInSS_Index =  IIf( ROCInS2 > 0 ,IIf( MA( ROC( C ,10 ) ,10 ) > 0 ,5 ,0 ) 
,0 );

// RSI
RSIInS = IIf( RSI(14 ) > 70 ,5 ,IIf( RSI(14 ) < 30 ,-5 ,0 ) );

// Stochastic
STOdInS = IIf( StochD(14 ,3 ) > 80 ,5 ,IIf( StochD(14 ,3 ) < 20 ,-5 ,0 ) );
STOkInS =IIf( StochK(14 ,1) > 80 ,5 ,IIf( StochK(14 ,1 ) < 20 ,-5 ,0 ) );

InSync_Index = 50+ CCIInS+ BOLInSLL  + RSIInS + STOkInS + STOdInS + 
MFIInS  + EMVInSB + EMVInSS + ROCInSS_Index+ ROCInSB
+ Ref (PDOInSS ,-10 ) + Ref (PDOInSB ,-10 )  +MACDInSS + MACDInSB  ;

Plot(InSync_Index,"InSync Index", 6,1);
Plot(20,"",2);  Plot(75,"",2); Plot(50,"",5);

/////////////////////end //////////////////////////////



At 17:11 01-09-2010 01-09-2010, you wrote:
>
>
>I searched through some of my old disk drives from a few years back and 
>came across the Insync code I had for TradeStation.  I had originally paid 
>Samuel Tennyson to write this for me in terms of TradeStation.
>
>Insync is a consensus indicator and some may find it of use.
>
>I have included the TradeStation code for this below and perhaps someone 
>here might code it up in AFL and put it in our library.   I also found the 
>original reference to Insync in Technical analysis of Stocks and 
>Commodities as well as some MetaStock code.
>
><http://store.traders.com/-v13-c01-insync-pdf.html>Stocks and Commodities
>
><http://www.equis.com/customer/resources/formulas/formula.aspx?Id=27>MetaStock 
>
>
>
>Comments are enclosed with {}
>
>____________________________________________ ___
>Insync code for TradeStation:
>_______________________________________________
>
>{
>
>
>Threshold type
>        Periods    Pre -Sell    -Buy
>-----------------------------------
>mfi        14            80      20
>bollb      20            95       5
>fastd      14            80      20
>fastk      14            85      15
>rsi        14            75      30
>cci        14          +100    -100
>
>Moving Average type
>        Periods         Sell     Buy
>-----------------------------------
>roc        10            10      10       Average
>eom        13            10      10       Average
>macd    12/25             9       9       Average
>pdo        18            10      10       xAverage
>
>
>}
>
>Inputs: PreBuy (Numeric), PreSel (Numeric) ;
>
>Vars  : xinsync(0), BollB     (0) ;
>Vars  : eom     (0), vrt.m.f.i (0) ;
>
>xinsync= 50 ;
>
>Value1 = StdDev (Close,  20) * 2.0 ;
>if (2 * Value1 <> 0) then
>   BollB = ((Close + Value1 - Average (Close,  20)) /
>                (2 * Value1)) * 100.0 ;
>
>EOM = vrt.Ease.Of.Movement (13) * 100000 ;
>vrt.M.F.I = vrt.Money.Flow.Index (Close, 14) ;
>
>{ Pre Sell  }
>
>if (vrt.M.F.I       >   60) then xinsync= xinsync+  5.0 ;
>if (BollB           >   95) then xinsync= xinsync+  5.0 ;
>if (CCI        (14) > +100) then xinsync= xinsync+  5.0 ;
>if (FastD      (14) >   80) then xinsync= xinsync+  5.0 ;
>if (FastK      (14) >   80) then xinsync= xinsync+  5.0 ;
>if (RSI (C lose, 14) >   65) then xinsync= xinsync+  5.0 ;
>
>if (         (Close - XAverage (Close, 18)) -
>     XAverage (Close - XAverage (Close, 18), 10) > 0) and
>    (XAverage (Close - XAverage (Close, 18), 10) > 0)
>                             then xinsync= xinsync+  5.0 ; { pdo }
>
>if (Average (MACD (Close, 12, 25), 9) > 0) and
>    (Average (MACD (Close, 12, 25), 9) <
>              MACD (Close, 12, 25))
>                             then xinsync= xinsync+  5 ;
>
>if (Average (RateOfChange (Close, 10), 10) > 0) and
>    (Average (RateOfChange (Close, 10), 10) <
>              RateOfChange (Close, 10))
>                             then xinsync= xinsync+  5 ;
>
>if (Average (EOM, 10) >   0) and
>    (Average (EOM, 10) < EOM)
>                             then xinsync= xinsync+  5 ;
>
>{ Pre  Buy }
>
>if (vrt.M.F.I       <   40) then xinsync= xinsync-  5.0 ;
>if (BollB           <    5) then xinsync= xinsync-  5.0 ;
>if (FastK      (14) <   20) then xinsync= xinsync-  5.0 ;
>if (FastD      (14) <   20) then xinsync= xinsync-  5.0 ;
>if (RSI (Close, 14) <   35) then xinsync= xinsync-  5.0 ;
>if (CCI        (14) < -100) then xinsync= xinsync-  5.0 ;
>
>if (         (Close - XAverage (Close, 18)) -
>     XAverage (Close - XAverage (Close, 18), 10) < 0) and
>    (XAverage (Close - XAverage (Close, 18), 10) < 0)
>                             then xinsync= xinsync-  5.0 ;
>
>if (Average (MACD (Close, 12, 25), 9) < 0) and
>    (Average (MACD (Close, 12, 25), 9) >
>              MACD (Close, 12, 25))
>                             then xinsync= xinsync-  5.0 ;
>
>if (Average (RateOfChange (Close, 10), 10) < 0) and
>&n
>bsp;  (Average (RateOfChange (Close, 10), 10) >
>              RateOfChange (Close, 10))
>                             then xinsync= xinsync-  5.0 ;
>
>if (Average (EOM, 10) <   0) and
>    (Average (EOM, 10) > EOM)
>                             then xinsync= xinsync-  5.0 ;
>{
>Plot1 (InSync, "InSync") ;
>Plot2 (PreBuy, "PreBuy") ;
>Plot3 (PreSel, "PreSel") ;
>}
>{
>     This enables the Alert feature of the Auto-Analyst for
>   all versions of SuperCharts and Version 3.5 of TradeStation.
>
>if (InSync <= PreBuy) or
>    (InSync >= PreSel) then Alert = TRUE ;
>
>     Do not forget to turn on the check box found in File,
>   Properties, Alert.
>
>     Here is an alternate syntax that might be more generic.
>
>if (Plot1 <= Plot2) or
>    (Plot1 >= Plot3) then Alert = TRUE ;
>
>
>if (Plot1 crosses above Plot2) then Alert = TRUE;
>}
>
>{print (file("C:\insync"),xinsync:6:0);}
>insync = xinsync;
>
>____________________________________________________
>
>Insync usage as an Indicator:
>____________________________________________________
>
>
>
>Inputs: BuyZone(5), SellZone(95);
>Vars:BZColor(Green), SZColor(Magenta);
>
>Plot1(insync(BuyZone, SellZone), "Insync");
>Plot2(BuyZone, "BuyZone");
>Plot3(SellZone, "SellZone");
>
>If Plot1 >= SellZone then Begin
>Alert("The Insync is in overbought territory");
>SetPlotColor(1, SZColor);
>End
>Else
>If Plot1 <= BuyZone then Begin
>Alert("The Insync is in oversold territory");
>SetPlotColor(1, BZColor);
>End;
>
>____________________________________________________
>
>Insync usage as a System:
>____________________________________________________
>
>Variables:mlt(3.7);
>
>If CurrentBar = 1 then
>Begin
>Print("");
>Print("Symbol ", GetSymbolName);
>End;
>
>Value1 = InSyncl(5, 95);
>Value2 = 999999;
>
>If (Value1[1] <= 5) and (Value1[0] > 5) Then
>Begin
>print(date:6:0, " open ", open, " atr ", (AvgTrueRange(20)),
>" open + var + atr ", open+(mlt * AvgTrueRange(20)),
>" Open profit ", c - entryprice );
>Buy("Insync") open today + (mlt * AvgTrueRange(20)) stop;
>end;
>
>{If (Value1[1] <= 5) and (Value1[0] > 5) Then
>Begin
>Value2 = Open;
>Buy("Insync+atr") ValBegin (.5 * AvgTrueRange(15)) Stop;
>End else
>Begin
>Value2 = 999999;
>end;
>}
>
>
>
>
>

Reply via email to