up3x1_Investor

Price Data Components
Series array that contains the highest prices of each barSeries array that contains the lowest prices of each barSeries array that contains open prices of each barSeries array that contains close prices for each bar
Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt Closes Orders by itself It can change open orders parameters, due to possible stepping strategy
Indicators Used
Moving average indicator
0 Views
0 Downloads
0 Favorites

Profitability Reports

AUD/USD Oct 2024 - Jan 2025
0.00 %
Total Trades 1
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff 120.00
Gross Profit 120.00
Gross Loss 0.00
Total Net Profit 120.00
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
24.00 %
Total Trades 6
Won Trades 2
Lost trades 4
Win Rate 0.33 %
Expected payoff -62.50
Gross Profit 120.00
Gross Loss -495.00
Total Net Profit -375.00
-100%
-50%
0%
50%
100%
up3x1_Investor
//+------------------------------------------------------------------+
//|                                               up3x1_investor.mq4 |
//|                                Copyright © 2006, izhutov aKa PPP |
//|                                                izhutov@yandex.ru |
//+------------------------------------------------------------------+
#define MAGICMA  20050611

extern double Lots               = 0.1;
extern double MaximumRisk        = 0.2;
extern double DecreaseFactor     = 3;
extern double TakeProfit         = 60;
extern double StopLoss           = 60;
extern double TrailingStop       = 10;
//double Points;
//
double dbStopLoss;
 double dsStopLoss;
 double dbTakeProfit;
 double dsTakeProfit;


int init ()
  {
  // Points = MarketInfo (Symbol(), MODE_POINT);

   return(0);
  }


void start()
  {

   if(Bars<100 || IsTradeAllowed()==false) return;
   if(DayOfWeek()==1) return;

   


   if(CalculateCurrentOrders(Symbol())==0) CheckForOpen();
   else                                    CheckForClose();

  }


int CalculateCurrentOrders(string symbol)
  {
   int buys=0,sells=0;

   for(int i=0;i<OrdersTotal();i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==MAGICMA)
        {
         if(OrderType()==OP_BUY)  buys++;
         if(OrderType()==OP_SELL) sells++;
        }
     }

   if(buys>0) return(buys);
   else       return(-sells);
  }

double LotsOptimized()
  {
   double lot=Lots;
   int    orders=HistoryTotal();    
   int    losses=0;                  
   lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/1000.0,1);

   if(DecreaseFactor>0)
     {
      for(int i=orders-1;i>=0;i--)
        {
         if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) { Print("Error in history!"); break; }
         if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL) continue;
         //----
         if(OrderProfit()>0) break;
         if(OrderProfit()<0) losses++;
        }
      if(losses>1) lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,1);
     }

   if(lot<0.1) lot=0.1;
   return(lot);
  }

void CheckForOpen()
  {

   double HI_1;
   double LO_1;
   double HI_2;
   double LO_2;
   double HI_3;
   double LO_3;
   double OP_1;
   double CL_1;
   double OP_2;
   double CL_2;
   double OP_3;
   double CL_3;
   double ma24_1;
   double ma60_1;
   double ma24_0;
   double ma60_0;
   int    res;

   if(Volume[0]>1) return;

   HI_1=iHigh(NULL,0,1);
   LO_1=iLow(NULL,0,1);
   HI_2=iHigh(NULL,0,2);
   LO_2=iLow(NULL,0,2);
   HI_3=iHigh(NULL,0,3);
   LO_3=iLow(NULL,0,3);
   OP_1=iOpen(NULL,0,1);
   CL_1=iClose(NULL,0,1);
   OP_2=iOpen(NULL,0,2);
   CL_2=iClose(NULL,0,2);
   OP_3=iOpen(NULL,0,3);
   CL_3=iClose(NULL,0,3);
   ma24_1=iMA(NULL,0,24,0,0,0,1);
   ma24_0=iMA(NULL,0,24,0,0,0,0);
   ma60_1=iMA(NULL,0,60,0,0,0,1);
   ma60_0=iMA(NULL,0,60,0,0,0,0);
   
   
   
 dbTakeProfit=Ask+TakeProfit*Point;
 dsTakeProfit=Bid-TakeProfit*Point;
 
if ( StopLoss > 0 ) {
   
   dsStopLoss = Ask+StopLoss*Point   ;
   dbStopLoss = Bid-StopLoss*Point;
   
   

}

   
   
   
//bay
if (HI_1-LO_1>0.0060 && OP_1<CL_1 && OP_1-CL_1>0.0050)
     {
     
     
     res=OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,dbStopLoss, dbTakeProfit,"",MAGICMA,0,Blue);
     return;
     }
//sell
if (HI_1-LO_1>0.0060 && OP_1>CL_1 && OP_1-CL_1>0.0050)

     {
      res=OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,3,dsStopLoss, dsTakeProfit,"",MAGICMA,0,Red);
      return;
     }


  }

void CheckForClose()
  {
   double ma24_1;
   double ma60_1;
   double ma24_0;
   double ma60_0;
   if(Volume[0]>1) return;
   ma24_1=iMA(NULL,0,24,0,0,0,1);
   ma24_0=iMA(NULL,0,24,0,0,0,0);
   ma60_1=iMA(NULL,0,60,0,0,0,1);
   ma60_0=iMA(NULL,0,60,0,0,0,0);
   
   for(int i=0;i<OrdersTotal();i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)        break;
      if(OrderMagicNumber()!=MAGICMA || OrderSymbol()!=Symbol()) continue;
      
      if(OrderType()==OP_BUY)
        {
      if (ma24_0==ma60_0) OrderClose(OrderTicket(),OrderLots(),Bid,3,White);
         break;
        }
if(TrailingStop>0)  
              {                
               if(Bid-OrderOpenPrice()>Point*TrailingStop)
                 {
                  if(OrderStopLoss()<Bid-Point*TrailingStop)
                    {
                     OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Red);
                     return(0);
                    }
                 }
              }        
        
        
      if(OrderType()==OP_SELL)
        {
      if (ma24_0==ma60_0) OrderClose(OrderTicket(),OrderLots(),Ask,3,White);
   
   
         break;
        }
if(TrailingStop>0)  
              {              
               if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
                 {
                  if(OrderStopLoss()==0.0 || 
                     OrderStopLoss()>(Ask+Point*TrailingStop))
                    {
                     OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);
                     return(0);
                    }
                 }
              }     
     }


  }  		


Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---