Simple Coding Help - No Promise.

Hello Friends

I am logging on to TJ after ages . . . .

Feels nice to see this thread still going strong . . . due to helping nature of few members.

Specially need to mention Pratap, thanks buddy . . .

Also Abhig10 . . . Great going . . .

Have not read everything . . . thanks to all those who are helping . . .

I will still not be able to participate on this thread, but intend to get back to FTT by mid April . . .

Happy :)
 
I have designed an auto trade script for NEST Plus and combined with an AFL of mine. The stock that need to be traded using that AFL are grouped into a watch list. How do I trade all the stocks in the watch list at the same time?

Hope it is clear what I am trying to say.

Its ok sir. As a matter of fact I know that it is possible and some of the members here have it working. I was thinking if anyone here has already tried to do it or have it working may give me a better head start then my current scenario.

I have a scenario in mind where we can capture OHLC of each stock using foreign( TICKER, DATAFIELD, fixup = 1) in a loop and then put all next part into another loop. What worries me here is if it would be feasible enough and be able to take the load during RT.
Wondering if anyone could help me with this. I just want to trade multiple stocks at the same time.
Looping through a small watch list should work, as long as you don't intend to do it for all 2000-3000 ticker in your DB :)

Also you can restrict it to run on close of every 5/15 minutes . . .


btw, have you thought of using excel? As excel and Ami seem to have some special Dostana :D

The workflow should be something like this

1. Create an instance of AB from excel . . .
2. run the scan and import its output into excel
3. validate/fire the order from excel

Maybe you can use the code base of RTNest to get started with
or get some help from Josh . . .


Happy :)
 

amitrandive

Well-Known Member
Hi All

Just saw this on the net for Metatrader.Is this possible in AmiBroker?





Code:
//+==================================================================+
//|                                                        Exp_6.mq4 |
//|                             Copyright © 2007,   Nikolay Kositsin | 
//|                              Khabarovsk,   [email protected] | 
//+==================================================================+
#property copyright "Copyright © 2007, Nikolay Kositsin"
#property link "[email protected]"
//----+ +-------------------------------------------------------------------------------+
//---- EA INPUT PARAMETERS FOR BUY TRADES 
extern bool   Test_Up = true;//filter of trade calculations direction
extern int    Timeframe_Up = 240;
extern double Money_Management_Up = 0.1;
extern int    LengthA_Up = 4;  // smoothing depth of the quick moving
extern int    PhaseA_Up = 100; // parameter changing in the range 
          //-100 ... +100, influences the quality of transient process of quick moving
extern int    IPCA_Up = 0;/* Selecting prices, on which the indicator will be 
calculated by the quick moving (0-CLOSE, 1-OPEN, 2-HIGH, 3-LOW, 4-MEDIAN, 5-TYPICAL, 
6-WEIGHTED, 7-Heiken Ashi Close, 8-SIMPL, 9-TRENDFOLLOW, 10-0.5*TRENDFOLLOW, 
11-Heiken Ashi Low, 12-Heiken Ashi High, 13-Heiken Ashi Open, 
14-Heiken Ashi Close.) */
extern int    LengthB_Up = 4; // smoothing depth increment of slow moving to quick one
extern int    PhaseB_Up = 100; // parameter changing in the range 
          //-100 ... +100, influences the quality of transient process of slow moving; 
extern int    IPCB_Up = 0;/* Selecting prices, on which the indicator will be 
calculated by the slow moving (0-CLOSE, 1-OPEN, 2-HIGH, 3-LOW, 4-MEDIAN, 5-TYPICAL, 
6-WEIGHTED, 7-Heiken Ashi Close, 8-SIMPL, 9-TRENDFOLLOW, 10-0.5*TRENDFOLLOW, 
11-Heiken Ashi Low, 12-Heiken Ashi High, 13-Heiken Ashi Open, 
14-Heiken Ashi Close.) */
extern int    STOPLOSS_Up = 50;  // stop loss
extern int    TAKEPROFIT_Up = 100; // take profit
extern bool   ClosePos_Up = true; // forced position closing allowed
//----+ +-------------------------------------------------------------------------------+
//---- EA INPUT PARAMETERS FOR SELL TRADES 
extern bool   Test_Dn = true;//filter of trade calculations direction
extern int    Timeframe_Dn = 240;
extern double Money_Management_Dn = 0.1;
extern int    LengthA_Dn = 4;  // smoothing depth of the quick moving
extern int    PhaseA_Dn = 100; // parameter changing in the range
         // -100 ... +100, influences the quality of transient process of quick moving; 
extern int    IPCA_Dn = 0;/* Selecting prices, on which the indicator will be 
calculated by the quick moving (0-CLOSE, 1-OPEN, 2-HIGH, 3-LOW, 4-MEDIAN, 5-TYPICAL, 
6-WEIGHTED, 7-Heiken Ashi Close, 8-SIMPL, 9-TRENDFOLLOW, 10-0.5*TRENDFOLLOW, 
11-Heiken Ashi Low, 12-Heiken Ashi High, 13-Heiken Ashi Open, 
14-Heiken Ashi Close.) */
extern int    LengthB_Dn = 4; // smoothing depth increment of slow moving to quick one
extern int    PhaseB_Dn = 100; // parameter changing in the range
         // -100 ... +100, influences the quality of transient process of slow moving; 
extern int    IPCB_Dn = 0;/* Selecting prices, on which the indicator will be 
calculated by the slow moving(0-CLOSE, 1-OPEN, 2-HIGH, 3-LOW, 4-MEDIAN, 5-TYPICAL, 
6-WEIGHTED, 7-Heiken Ashi Close, 8-SIMPL, 9-TRENDFOLLOW, 10-0.5*TRENDFOLLOW, 
11-Heiken Ashi Low, 12-Heiken Ashi High, 13-Heiken Ashi Open, 
14-Heiken Ashi Close.) */
extern int   STOPLOSS_Dn = 50;  // stop loss
extern int   TAKEPROFIT_Dn = 100; // take profit
extern bool   ClosePos_Dn = true; // forced position closing allowed
//----+ +-------------------------------------------------------------------------------+
//---- Integer variables for the minimum of calculation bars
int MinBar_Up, MinBar_Dn;
//+==================================================================+
//| Custom Expert functions                                          |
//+==================================================================+
#include <Lite_EXPERT1.mqh>
//+==================================================================+
//| Custom Expert initialization function                            |
//+==================================================================+
int init()
  {
//---- Checking the correctness of Timeframe_Up variable value
   if (Timeframe_Up != 1)
    if (Timeframe_Up != 5)
     if (Timeframe_Up != 15)
      if (Timeframe_Up != 30)
       if (Timeframe_Up != 60)
        if (Timeframe_Up != 240)
         if (Timeframe_Up != 1440)
           Print(StringConcatenate("Parameter Timeframe_Up cannot ",  
                                  "be equal to ", Timeframe_Up, "!!!"));
//---- Checking the correctness of Timeframe_Dn variable value 
   if (Timeframe_Dn != 1)
    if (Timeframe_Dn != 5)
     if (Timeframe_Dn != 15)
      if (Timeframe_Dn != 30)
       if (Timeframe_Dn != 60)
        if (Timeframe_Dn != 240)
         if (Timeframe_Dn != 1440)
           Print(StringConcatenate("Parameter Timeframe_Dn cannot ",  
                                 "be equal to ", Timeframe_Dn, "!!!")); 
//---- Initialization of variables            
   MinBar_Up = 4 + 30;
   MinBar_Dn = 4 + 30;                                        
//---- end of initialization
   return(0);
  }
//+==================================================================+
//| expert deinitialization function                                 |
//+==================================================================+  
int deinit()
  {
//----+
   
    //---- End of EA deinitialization
    return(0);
//----+ 
  }
//+==================================================================+
//| Custom Expert iteration function                                 |
//+==================================================================+
int start()
  {
   //----+ Declaring local variables
   int    bar;
   double MovA[2], MovB[2];
   //----+ Declaring static variables
   static int LastBars_Up, LastBars_Dn;
   static bool BUY_Sign, BUY_Stop, SELL_Sign, SELL_Stop;
   
   //----++ CODE FOR LONG POSITIONS
   if (Test_Up)
    {
      int IBARS_Up = iBars(NULL, Timeframe_Up);
      
      if (IBARS_Up >= MinBar_Up)
       {
         if (LastBars_Up != IBARS_Up)
          {
           //----+ Initialization of variables 
           BUY_Sign = false;
           BUY_Stop = false;
           LastBars_Up = IBARS_Up;
           
           //----+ CALCULATING INDICATOR VALUES AND UPLOADING THEM TO BUFFERS        
           for(bar = 1; bar < 3; bar++)
                     MovA[bar - 1] =                  
                         iCustom(NULL, Timeframe_Up, 
                                "JJMA", LengthA_Up, PhaseA_Up, 
                                                   0, IPCA_Up, 0, bar);
           for(bar = 1; bar < 3; bar++)
                MovB[bar - 1] =                  
                   iCustom(NULL, Timeframe_Up, 
                     "JJMA", LengthA_Up + LengthB_Up, PhaseB_Up, 
                                                   0, IPCB_Up, 0, bar);
                                                   
           //----+ DEFINING SIGNALS FOR TRADES                                          
           if ( MovA[1] < MovB[1])
               if ( MovA[0] > MovB[0])
                        BUY_Sign = true;
                          
            if ( MovA[0] > MovB[0])
                        BUY_Stop = true;                                           
          }
          
          //----+ EXECUTION OF TRADES
          if (!OpenBuyOrder1(BUY_Sign, 1, Money_Management_Up, 
                                          STOPLOSS_Up, TAKEPROFIT_Up))
                                                                 return(-1);
          if (ClosePos_Up)
                if (!CloseOrder1(BUY_Stop, 1))
                                        return(-1);
        }
     }
     
   //----++ CODE FOR SHORT POSITIONS
   if (Test_Dn)
    {
      int IBARS_Dn = iBars(NULL, Timeframe_Dn);
      
      if (IBARS_Dn >= MinBar_Dn)
       {
         if (LastBars_Dn != IBARS_Dn)
          {
           //----+ Initialization of variables 
           SELL_Sign = false;
           SELL_Stop = false;
           LastBars_Dn = IBARS_Dn; 
           
           //----+ CALCULATING INDICATOR VALUES AND UPLOADING THEM TO BUFFERS
           for(bar = 1; bar < 3; bar++)
                     MovA[bar - 1] =                  
                         iCustom(NULL, Timeframe_Dn, 
                                "JJMA", LengthA_Dn, PhaseA_Dn, 
                                                   0, IPCA_Dn, 0, bar);
           for(bar = 1; bar < 3; bar++)
                MovB[bar - 1] =                  
                   iCustom(NULL, Timeframe_Dn, 
                     "JJMA", LengthA_Dn + LengthB_Dn, PhaseB_Dn, 
                                                   0, IPCB_Dn, 0, bar);
           
           //----+ DEFINING SIGNALS FOR TRADES                                          
           if ( MovA[1] > MovB[1])
               if ( MovA[0] < MovB[0])
                        SELL_Sign = true;
                          
            if ( MovA[0] < MovB[0])
                        SELL_Stop = true;                                                
          }
          //----+ EXECUTION OF TRADES
          if (!OpenSellOrder1(SELL_Sign, 2, Money_Management_Dn, 
                                            STOPLOSS_Dn, TAKEPROFIT_Dn))
                                                                   return(-1);
          if (ClosePos_Dn)
                if (!CloseOrder1(SELL_Stop, 2))
                                        return(-1);
        }
     }
//----+ 
    
    return(0);
  }
//+------------------------------------------------------------------+
 


Hello

Just posted a 5 minutes chart on Pratap's thread,
its better to post the code, before I start getting AFL requests for it, :)

Code:
st = Param("UP strength",0.5,0.5,5,0.5);
wk = Param("DN strength",0.5,0.5,5,0.5);

_SECTION_BEGIN("Nishant's Code from Amibroker Library");
No_of_Bars = 	BarCount - 1;
PL1 = LastValue(Trough(L,wk,2)); 							PL2 = LastValue(Trough(L,wk,1));
UB1 = No_of_Bars - LastValue(TroughBars(L,wk,2)); 		UB2 = No_of_Bars - LastValue(TroughBars(L,wk,1));  
UpTrendLine = LineArray(UB1,PL1,UB2,PL2,1);				UTLine = LineArray(UB1,PL1,UB2,PL2,0);

PH1 = LastValue(Peak(H,st,2)); 							PH2 = LastValue(Peak(H,st,1)); 
DB1 = No_of_Bars - LastValue(PeakBars(H,st,2)); 		DB2 = No_of_Bars - LastValue(PeakBars(H,st,1));  
DownTrendLine = LineArray(DB1,PH1,DB2,PH2,1);			DTLine = LineArray(DB1,PH1,DB2,PH2,0);

Plot( UpTrendLine , "", colorGreen,styleLine | styleNoTitle |styleNoLabel|styleNoRescale); 
Plot( UTLine ,"", colorGreen,styleLine | styleNoTitle | styleNoLabel|styleNoRescale); 

Plot( DownTrendLine ,"", colorRed,styleLine | styleNoTitle |styleNoLabel|styleNoRescale); 
Plot( DTLine ,"", colorRed,styleLine | styleNoTitle |styleNoLabel|styleNoRescale);
	
Plot(LineArray( DB2-20, PH2, BarCount,PH2, 0 ),"",colorGreen,styleNoRescale,0,0,20);
Plot(LineArray( UB2-20, PL2, BarCount,PL2, 0 ),"",colorRed,styleNoRescale,0,0,20);

PlotText(" HH ", LastValue(BarIndex())+5,PH2+2, colorRed);
PlotText(" LL ", LastValue(BarIndex())+5,PL2+2, colorGreen);
PlotOHLC(DownTrendLine,UpTrendLine,DownTrendLine,UpTrendLine ,"",ColorRGB(20,50,20),styleCloud|styleNoLabel);
	
_SECTION_END();

like to mention that the code is publicly posted on Amibroker Library
few years back, by some Nishant, all thanks go to him *. . .



Happy :)
 
Hi All

Just saw this on the net for Metatrader.Is this possible in AmiBroker?





Code:
//+==================================================================+
//|                                                        Exp_6.mq4 |
//|                             Copyright © 2007,   Nikolay Kositsin | 
//|                              Khabarovsk,   [email protected] | 
//+==================================================================+
#property copyright "Copyright © 2007, Nikolay Kositsin"
#property link "[email protected]"
//----+ +-------------------------------------------------------------------------------+
//---- EA INPUT PARAMETERS FOR BUY TRADES 
extern bool   Test_Up = true;//filter of trade calculations direction
extern int    Timeframe_Up = 240;
extern double Money_Management_Up = 0.1;
extern int    LengthA_Up = 4;  // smoothing depth of the quick moving
extern int    PhaseA_Up = 100; // parameter changing in the range 
          //-100 ... +100, influences the quality of transient process of quick moving
extern int    IPCA_Up = 0;/* Selecting prices, on which the indicator will be 
calculated by the quick moving (0-CLOSE, 1-OPEN, 2-HIGH, 3-LOW, 4-MEDIAN, 5-TYPICAL, 
6-WEIGHTED, 7-Heiken Ashi Close, 8-SIMPL, 9-TRENDFOLLOW, 10-0.5*TRENDFOLLOW, 
11-Heiken Ashi Low, 12-Heiken Ashi High, 13-Heiken Ashi Open, 
14-Heiken Ashi Close.) */
extern int    LengthB_Up = 4; // smoothing depth increment of slow moving to quick one
extern int    PhaseB_Up = 100; // parameter changing in the range 
          //-100 ... +100, influences the quality of transient process of slow moving; 
extern int    IPCB_Up = 0;/* Selecting prices, on which the indicator will be 
calculated by the slow moving (0-CLOSE, 1-OPEN, 2-HIGH, 3-LOW, 4-MEDIAN, 5-TYPICAL, 
6-WEIGHTED, 7-Heiken Ashi Close, 8-SIMPL, 9-TRENDFOLLOW, 10-0.5*TRENDFOLLOW, 
11-Heiken Ashi Low, 12-Heiken Ashi High, 13-Heiken Ashi Open, 
14-Heiken Ashi Close.) */
extern int    STOPLOSS_Up = 50;  // stop loss
extern int    TAKEPROFIT_Up = 100; // take profit
extern bool   ClosePos_Up = true; // forced position closing allowed
//----+ +-------------------------------------------------------------------------------+
//---- EA INPUT PARAMETERS FOR SELL TRADES 
extern bool   Test_Dn = true;//filter of trade calculations direction
extern int    Timeframe_Dn = 240;
extern double Money_Management_Dn = 0.1;
extern int    LengthA_Dn = 4;  // smoothing depth of the quick moving
extern int    PhaseA_Dn = 100; // parameter changing in the range
         // -100 ... +100, influences the quality of transient process of quick moving; 
extern int    IPCA_Dn = 0;/* Selecting prices, on which the indicator will be 
calculated by the quick moving (0-CLOSE, 1-OPEN, 2-HIGH, 3-LOW, 4-MEDIAN, 5-TYPICAL, 
6-WEIGHTED, 7-Heiken Ashi Close, 8-SIMPL, 9-TRENDFOLLOW, 10-0.5*TRENDFOLLOW, 
11-Heiken Ashi Low, 12-Heiken Ashi High, 13-Heiken Ashi Open, 
14-Heiken Ashi Close.) */
extern int    LengthB_Dn = 4; // smoothing depth increment of slow moving to quick one
extern int    PhaseB_Dn = 100; // parameter changing in the range
         // -100 ... +100, influences the quality of transient process of slow moving; 
extern int    IPCB_Dn = 0;/* Selecting prices, on which the indicator will be 
calculated by the slow moving(0-CLOSE, 1-OPEN, 2-HIGH, 3-LOW, 4-MEDIAN, 5-TYPICAL, 
6-WEIGHTED, 7-Heiken Ashi Close, 8-SIMPL, 9-TRENDFOLLOW, 10-0.5*TRENDFOLLOW, 
11-Heiken Ashi Low, 12-Heiken Ashi High, 13-Heiken Ashi Open, 
14-Heiken Ashi Close.) */
extern int   STOPLOSS_Dn = 50;  // stop loss
extern int   TAKEPROFIT_Dn = 100; // take profit
extern bool   ClosePos_Dn = true; // forced position closing allowed
//----+ +-------------------------------------------------------------------------------+
//---- Integer variables for the minimum of calculation bars
int MinBar_Up, MinBar_Dn;
//+==================================================================+
//| Custom Expert functions                                          |
//+==================================================================+
#include <Lite_EXPERT1.mqh>
//+==================================================================+
//| Custom Expert initialization function                            |
//+==================================================================+
int init()
  {
//---- Checking the correctness of Timeframe_Up variable value
   if (Timeframe_Up != 1)
    if (Timeframe_Up != 5)
     if (Timeframe_Up != 15)
      if (Timeframe_Up != 30)
       if (Timeframe_Up != 60)
        if (Timeframe_Up != 240)
         if (Timeframe_Up != 1440)
           Print(StringConcatenate("Parameter Timeframe_Up cannot ",  
                                  "be equal to ", Timeframe_Up, "!!!"));
//---- Checking the correctness of Timeframe_Dn variable value 
   if (Timeframe_Dn != 1)
    if (Timeframe_Dn != 5)
     if (Timeframe_Dn != 15)
      if (Timeframe_Dn != 30)
       if (Timeframe_Dn != 60)
        if (Timeframe_Dn != 240)
         if (Timeframe_Dn != 1440)
           Print(StringConcatenate("Parameter Timeframe_Dn cannot ",  
                                 "be equal to ", Timeframe_Dn, "!!!")); 
//---- Initialization of variables            
   MinBar_Up = 4 + 30;
   MinBar_Dn = 4 + 30;                                        
//---- end of initialization
   return(0);
  }
//+==================================================================+
//| expert deinitialization function                                 |
//+==================================================================+  
int deinit()
  {
//----+
   
    //---- End of EA deinitialization
    return(0);
//----+ 
  }
//+==================================================================+
//| Custom Expert iteration function                                 |
//+==================================================================+
int start()
  {
   //----+ Declaring local variables
   int    bar;
   double MovA[2], MovB[2];
   //----+ Declaring static variables
   static int LastBars_Up, LastBars_Dn;
   static bool BUY_Sign, BUY_Stop, SELL_Sign, SELL_Stop;
   
   //----++ CODE FOR LONG POSITIONS
   if (Test_Up)
    {
      int IBARS_Up = iBars(NULL, Timeframe_Up);
      
      if (IBARS_Up >= MinBar_Up)
       {
         if (LastBars_Up != IBARS_Up)
          {
           //----+ Initialization of variables 
           BUY_Sign = false;
           BUY_Stop = false;
           LastBars_Up = IBARS_Up;
           
           //----+ CALCULATING INDICATOR VALUES AND UPLOADING THEM TO BUFFERS        
           for(bar = 1; bar < 3; bar++)
                     MovA[bar - 1] =                  
                         iCustom(NULL, Timeframe_Up, 
                                "JJMA", LengthA_Up, PhaseA_Up, 
                                                   0, IPCA_Up, 0, bar);
           for(bar = 1; bar < 3; bar++)
                MovB[bar - 1] =                  
                   iCustom(NULL, Timeframe_Up, 
                     "JJMA", LengthA_Up + LengthB_Up, PhaseB_Up, 
                                                   0, IPCB_Up, 0, bar);
                                                   
           //----+ DEFINING SIGNALS FOR TRADES                                          
           if ( MovA[1] < MovB[1])
               if ( MovA[0] > MovB[0])
                        BUY_Sign = true;
                          
            if ( MovA[0] > MovB[0])
                        BUY_Stop = true;                                           
          }
          
          //----+ EXECUTION OF TRADES
          if (!OpenBuyOrder1(BUY_Sign, 1, Money_Management_Up, 
                                          STOPLOSS_Up, TAKEPROFIT_Up))
                                                                 return(-1);
          if (ClosePos_Up)
                if (!CloseOrder1(BUY_Stop, 1))
                                        return(-1);
        }
     }
     
   //----++ CODE FOR SHORT POSITIONS
   if (Test_Dn)
    {
      int IBARS_Dn = iBars(NULL, Timeframe_Dn);
      
      if (IBARS_Dn >= MinBar_Dn)
       {
         if (LastBars_Dn != IBARS_Dn)
          {
           //----+ Initialization of variables 
           SELL_Sign = false;
           SELL_Stop = false;
           LastBars_Dn = IBARS_Dn; 
           
           //----+ CALCULATING INDICATOR VALUES AND UPLOADING THEM TO BUFFERS
           for(bar = 1; bar < 3; bar++)
                     MovA[bar - 1] =                  
                         iCustom(NULL, Timeframe_Dn, 
                                "JJMA", LengthA_Dn, PhaseA_Dn, 
                                                   0, IPCA_Dn, 0, bar);
           for(bar = 1; bar < 3; bar++)
                MovB[bar - 1] =                  
                   iCustom(NULL, Timeframe_Dn, 
                     "JJMA", LengthA_Dn + LengthB_Dn, PhaseB_Dn, 
                                                   0, IPCB_Dn, 0, bar);
           
           //----+ DEFINING SIGNALS FOR TRADES                                          
           if ( MovA[1] > MovB[1])
               if ( MovA[0] < MovB[0])
                        SELL_Sign = true;
                          
            if ( MovA[0] < MovB[0])
                        SELL_Stop = true;                                                
          }
          //----+ EXECUTION OF TRADES
          if (!OpenSellOrder1(SELL_Sign, 2, Money_Management_Dn, 
                                            STOPLOSS_Dn, TAKEPROFIT_Dn))
                                                                   return(-1);
          if (ClosePos_Dn)
                if (!CloseOrder1(SELL_Stop, 2))
                                        return(-1);
        }
     }
//----+ 
    
    return(0);
  }
//+------------------------------------------------------------------+

Not seen the code you have posted
but from image it looks like . . .
it is same as simple MA Cross i.e.

A = MA(C,20);
B = MA(C,30);
Buy = Cross(A,B);
Sell = Cross(B,A);


Buy = A > B and Ref(A,-1) < Ref(B,-1);

which is same as Buy = Cross(A,B)


Happy :)
 

amitrandive

Well-Known Member
Not seen the code you have posted
but from image it looks like . . .
it is same as simple MA Cross i.e.

A = MA(C,20);
B = MA(C,30);
Buy = Cross(A,B);
Sell = Cross(B,A);


Buy = A > B and Ref(A,-1) < Ref(B,-1);

which is same as Buy = Cross(A,B)


Happy :)
Happy Sir

I do not have any programing knowledge, but from the image it seems that there is a crossover condition which acts two times to get the desired alert.
Like a Scissor Cross.

:confused:
 
Last edited:
Happy Sir

I do not have any programing knowledge, but from the image it seems that there is a crossover condition which acts two times to get the desired alert.
Like a Scissor Cross.

:confused:
the two conditions are as follows

on one bar A < B (value of ma A is less than value of ma B ) and on next bar now A > B . . . in Amibroker we use cross for same condition


Happy :)


But if you want double cross then it is also possible to code that

Code:
A = MA(C,20);
B = MA(C,30);
UP = Cross(A,B);
DN = Cross(B,A);

Buy = UP AND (Ref(DN,-1) or Ref(DN,-2)  or Ref(DN,-3) );
Sell = DN;
Short = DN AND (Ref(UP,-1) or Ref(UP,-2)  or Ref(UP,-3) );
Cover = UP;
The above will trigger buy/short only when it is after a whipsaw from last 3 bars . . .

Happy :)
 
Last edited:

amitrandive

Well-Known Member
the two conditions are as follows

on one bar A < B (value of ma A is less than value of ma B ) and on next bar now A > B . . . in Amibroker we use cross for same condition


Happy :)


But if you want double cross then it is also possible to code that

Code:
A = MA(C,20);
B = MA(C,30);
UP = Cross(A,B);
DN = Cross(B,A);

Buy = UP AND (Ref(DN,-1) or Ref(DN,-2)  or Ref(DN,-3) );
Sell = DN;
Short = DN AND (Ref(UP,-1) or Ref(UP,-2)  or Ref(UP,-3) );
Cover = UP;
The above will trigger buy/short only when it is after a whipsaw from last 3 bars . . .

Happy :)
Happy Sir

Thanks , will implement and get back back with any issues/comments.
:clap:
 
_SECTION_BEGIN("visual arrow ema cross over");
SetChartOptions(0,chartShowArrows|chartShowDates);
Plot( Close, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );


for(i=1; i < BarCount; i++)
{

Buy = IIf(H > 800 , 1 , 0);
PlotShapes(IIf(Buy==1, shapeUpArrow , shapeNone), colorGreen, 0,Low, Offset=-15);

Sell = IIf(L <720 , 1 , 0);
PlotShapes(IIf(Sell==1, shapeDownArrow, shapeNone), colorRed, 0,High, Offset=-15);

}
_SECTION_END();



Please correct my syntax
"Buy = ......"
"Sell = ......"

I want to buy a stock when it goes above 800 and sell when goes below 720
in the same form using loop


Thanx in advance
 
Last edited:

Nehal_s143

Well-Known Member
Hello Friends

I am logging on to TJ after ages . . . .

Feels nice to see this thread still going strong . . . due to helping nature of few members.

Specially need to mention Pratap, thanks buddy . . .

Also Abhig10 . . . Great going . . .

Have not read everything . . . thanks to all those who are helping . . .

I will still not be able to participate on this thread, but intend to get back to FTT by mid April . . .

Happy :)
Welcome back Happy Sir :clap:, we missed you.....
 

Similar threads