Author: O.Petersen
Price Data Components
Series array that contains the highest prices of each barSeries array that contains the lowest prices of 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 indicatorRelative strength index
0 Views
0 Downloads
0 Favorites

Profitability Reports

AUD/USD Oct 2024 - Jan 2025
0.00 %
Total Trades 0
Won Trades 0
Lost trades 0
Win Rate 0.0 %
Expected payoff 0.00
Gross Profit 0.00
Gross Loss 0.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.00 %
Total Trades 0
Won Trades 0
Lost trades 0
Win Rate 0.0 %
Expected payoff 0.00
Gross Profit 0.00
Gross Loss 0.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.00 %
Total Trades 0
Won Trades 0
Lost trades 0
Win Rate 0.0 %
Expected payoff 0.00
Gross Profit 0.00
Gross Loss 0.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%
Fibo4[1].1
//+------------------------------------------------------------------+
//|                                                        Fibo.mq4  |
/*	                             
	                                                      Lots := 1.00
	                                                   Stop Loss := 30
	                                                Take Profit := 100
	                                                Trailing Stop := 0
*/
//+------------------------------------------------------------------+
#property copyright "O.Petersen"
#property link      "O.P"

extern double Lots= 0.1;
extern double MaximumRisk= 0.1;
extern int StopLoss=49,TakeProfit=300,TrailingStop=26;
extern int StartHour=9,EndHour=18,Range=45,fib=50;
double H=0,L=0,ma=0,ma1=0,ma2=0,t1=0,t2=0,rsi=0;
int total,cnt;

//+------------------------------------------------------------------+
//| Calculate optimal lot size                                       |
//+------------------------------------------------------------------+
double LotsOptimized()
  {
   double lot=Lots;
   int    orders=HistoryTotal();     // history orders total
   int    losses=0;                  // number of losses orders without a break
//---- select lot size
   lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/1000.0,1);
//---- return lot size
   if(lot<0.1) lot=0.1;
   return(lot);
  }

int start(){

H=iHigh(NULL,PERIOD_D1,0);
L=iLow(NULL,PERIOD_D1,0);
ma=iMA(NULL,PERIOD_M30,20,0,MODE_SMA,PRICE_CLOSE,0);
ma1=iMA(NULL,PERIOD_M30,21,0,MODE_EMA,PRICE_CLOSE,0);
ma2=iMA(NULL,PERIOD_M30,21,1,MODE_EMA,PRICE_CLOSE,0);
rsi=iRSI(NULL,PERIOD_M30,8,PRICE_CLOSE,0);

  datetime some_time=iTime(NULL,PERIOD_D1,0);
  int      shift=iBarShift(NULL,PERIOD_M15,some_time);
  int      ht=Highest(NULL,PERIOD_M15,MODE_HIGH,shift,0);
  int      lt=Lowest(NULL,PERIOD_M15,MODE_LOW,shift,0);

total=OrdersTotal();
if(total<1) {
if (H-L<Range*Point) {
	if((Ask>ma) && (Ask>(L+(H-L)*(fib/100))) && (ma1>ma2) && (Hour()>StartHour) && ( Hour()<EndHour) && (rsi>60) && (ht>lt)){
		OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,5,Ask-StopLoss*Point,Ask+TakeProfit*Point,"Fibo",0,Blue);
		return;
		}

	if((Bid<ma) && (Bid<(H-(H-L)*(fib/100)))&& (ma1<ma2) && (Hour()>StartHour) && ( Hour()<EndHour) && (rsi<40) &&(lt>ht)){
		OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,5,Bid+StopLoss*Point,Bid-TakeProfit*Point,"Fibo",0,Red);
		return;
		}
	}	 
}
     int i;
if (Hour()==18){
for (i = OrdersTotal() - 1; i >= 0; i--)
{
OrderSelect(i, SELECT_BY_POS);
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),0,HotPink);
}
}

   // it is important to enter the market correctly, 
   // but it is more important to exit it correctly...  
   for(cnt=0;cnt<total;cnt++)
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if(OrderType()<=OP_SELL &&   // check for opened position 
         OrderSymbol()==Symbol())  // check for symbol
        {
         if(OrderType()==OP_BUY)   // long position is opened
           {
            // check for trailing stop
            if(TrailingStop>0)  
              {                 
               if(Bid-OrderOpenPrice()>Point*TrailingStop)
                 {
                  if(OrderStopLoss()<Bid-Point*TrailingStop)
                    {
                     OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);
                     return(0);
                    }
                 }
              }
           }
         else // go to short position
           {
            // check for trailing stop
            if(TrailingStop>0)  
              {                 
               if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
                 {
                  if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
                    {
                     OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);
                     return(0);
                    }
                 }
              }
           }
        }
     } 
   return(0);

  }
// the end.

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 ---