CCI_For_Gazuz2

Author: tonyc2a@yahoo.com
Orders Execution
Checks for the total of open ordersIt Closes Orders by itself It automatically opens orders when conditions are reachedIt can change open orders parameters, due to possible stepping strategy
Indicators Used
Commodity channel index
Miscellaneous
It issuies visual alerts to the screen
0 Views
0 Downloads
0 Favorites

Profitability Reports

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%
CCI_For_Gazuz2
//+------------------------------------------------------------------+
//|                                               CCI_For_Gazuz2.mq4 |
//|                                                tonyc2a@yahoo.com |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "tonyc2a@yahoo.com"
#property link      ""

extern int Risk=20;
extern int mm=1;
extern int CCI_Period=20;
extern int Slippage=4;
extern int Lots=1;
extern int StopLoss=60;
extern int TakeProfit=999;
extern int TrailingStop = 30;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//---- TODO: Add your code here.
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: Add your code here.
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
   double BuyCrossPoint=0;
   double SellCrossPoint=0;
   bool abv01=( iCCI(Symbol(),Period(),1,PRICE_CLOSE,1) > BuyCrossPoint );
   bool abv02=( iCCI(Symbol(),Period(),1,PRICE_CLOSE,2) > SellCrossPoint );
   bool blw01=( iCCI(Symbol(),Period(),1,PRICE_CLOSE,1) < SellCrossPoint );
   bool blw02=( iCCI(Symbol(),Period(),1,PRICE_CLOSE,2) < BuyCrossPoint );

//---- TODO: Add your code here.

   //+----Main Section: Determines entries and exits-----------------+ 
   for(int x=1;x<OrdersTotal();x++){
      OrderSelect(x, SELECT_BY_POS, MODE_TRADES);
      if(OrderType()==OP_BUY && OrderSymbol()==Symbol()){
         if(abv02 && blw01){
            OrderClose(x,OrderLots(),OrderClosePrice(),Slippage,White);
            Alert("CCI Expert Closed Buy Trade"+"."+Symbol());
            return(0);
            }//end if
         }//end if
      if(OrderType()==OP_SELL && OrderSymbol()==Symbol()){
         if(abv01 && blw02){
            OrderClose(x,OrderLots(),OrderClosePrice(),Slippage,Gold);
            Alert("CCI Expert Closed Sell Trade"+"."+Symbol());
            return(0);
            }//end if
         }//end if
      }//end for
      
   if(OrdersTotal()<1){
      if(abv02 && blw01){
         OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,Bid+StopLoss*Point,Bid-TakeProfit*Point,"CCI Expert Short Trade",0,0,Gold);
         Alert("CCI Expert Opened a Short Trade: "+Symbol());
         return(0);
         }
      if(abv01 && blw02){
         OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,Ask-StopLoss*Point,Ask+TakeProfit*Point,"CCI Expert Long Trade",0,0,White);
         Alert("CCI Expert Opened a Long Trade: "+Symbol());
         return(0);
         }
      }
   //+---------------------------------------------------------------+ 
   
   
   //+----Trailing Stop Section--------------------------------------+
   for (int i = 0; i < OrdersTotal(); i++){
      OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      if (OrderType() == OP_BUY){
         if (Bid - OrderOpenPrice() > TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT)){
            if (OrderStopLoss() < Bid - TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT)){
               OrderModify(OrderTicket(), OrderOpenPrice(), Bid - TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT), OrderTakeProfit(), Red);
            }
         }
      } 
      else if(OrderType() == OP_SELL){
         if(OrderOpenPrice() - Ask > TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT)){
            if((OrderStopLoss() > Ask + TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT)) || (OrderStopLoss() == 0)){
               OrderModify(OrderTicket(), OrderOpenPrice(),Ask + TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT), OrderTakeProfit(), 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 ---