chinkoucross
Download scriptThis automated trading script is designed to monitor financial markets and provide real-time alerts based on specific price action signals derived from the Ichimoku Cloud technical analysis indicator.
Core Trading Logic
The primary engine of this script relies on identifying a "cross" in the Chinkou Span (also known as the Lagging Span). The Chinkou Span is a component of the Ichimoku system that plots past prices relative to current time; it serves as a momentum indicator to help traders determine if the current price trend is moving in a specific direction.
The script evaluates two specific conditions to trigger an alert:
- Buy Signal (Long): The script looks for a moment where the closing price of a previous candle moves from below to above the Chinkou Span line.
- Sell Signal (Short): The script identifies when the closing price moves from above to below the Chinkou Span line.
Operational Behavior
To ensure it provides relevant information without creating unnecessary noise, the script follows these operational guidelines:
- Trade Awareness: The script actively scans your current account to see if there are any existing positions or pending orders (Buy, Sell, Buy Limit, Buy Stop, etc.) on the specific currency pair you are viewing.
- Single Entry Alerting: It is programmed to trigger an alert only when no other trades are currently active. This prevents the script from spamming notifications if you already have a position open in the market.
- Real-Time Monitoring: The logic constantly compares the most recent price data against the indicator values to detect the exact moment a "cross" occurs.
- Notification System: Once a crossover condition is met and all other conditions are satisfied (no active trades), the script generates an immediate alert on your platform, notifying you of the trend shift for the specific symbol and timeframe you are monitoring.
Summary for the User
Essentially, this tool acts as a vigilant observer. It watches the Ichimoku Cloud's Lagging Span for every price movement. When it detects a significant shift in momentum—signaling either a potential upward move (Long) or a downward move (Short)—it alerts you immediately, provided you aren't already currently trading that specific asset.
extern double Lots = 0.1;
extern int StopLoss = 15;
extern int TrailingStop = 15;
extern int TakeProfit = 300;
extern int Slippage = 3;
double Points, lastTradeTime = 0;
void printDebug()
{
}
bool newDay()
{
if (TimeDay(Time[0])!=TimeDay(Time[1]))
return (true);
else
return (false);
}
int init ()
{
Points = MarketInfo (Symbol(), MODE_POINT);
return(0);
}
int deinit()
{
return(0);
}
int start()
{
double lot=Lots, stopLoss=StopLoss, trailingStop=TrailingStop, takeProfit=TakeProfit;
string symbol = "";
int i, orderType, orderTicket, total;
int openTrades = 0, openOrders = 0, openBuy = 0, openSell = 0;
int openBuyLimit = 0, openSellLimit = 0, openBuyStop = 0, openSellStop = 0;
int minutesBetweenTrades = 30;
double stopLossMult = 1, trailingStopMult = 1, takeProfitMult = 10;
double chinkouSpanLong, chinkouSpanShort;
datetime orderCloseTime;
int numOfLosingTradesToday = 0;
bool trailingRules = false ,debug = true;
if (newDay())
numOfLosingTradesToday = 0;
total = OrdersTotal();
for(i=0;i<total;i++)
{
OrderSelect(i,SELECT_BY_POS);
symbol = OrderSymbol();
orderType = OrderType();
orderTicket = OrderTicket();
/* 0-OP_BUY 1-OP_SELL 2-OP_BUYLIMIT 3-OP_BUYSTOP 4-OP_SELLLIMIT 5-OP_SELLSTOP */
if (symbol == Symbol()
&& orderType == 0)
{
openBuy++;
openTrades++;
}
if (symbol == Symbol()
&& orderType == 1)
{
openSell++;
openTrades++;
}
if (symbol == Symbol()
&& orderType == 2)
{
openBuyLimit++;
openTrades++;
}
if (symbol == Symbol()
&& orderType == 3)
{
openBuyStop++;
openTrades++;
}
if (symbol == Symbol()
&& orderType == 4)
{
openSellLimit++;
openTrades++;
}
if (symbol == Symbol()
&& orderType == 5)
{
openSellStop++;
openTrades++;
}
}
stopLoss=StopLoss*Point;
trailingStop=TrailingStop*Point;
takeProfit=TakeProfit*Point;
if (iClose(NULL, 0, 27) > iIchimoku(NULL, 0, 9, 26, 52, MODE_CHINKOUSPAN, 27) &&
iClose(NULL, 0, 28) <= iIchimoku(NULL, 0, 9, 26, 52, MODE_CHINKOUSPAN, 28))
{
chinkouSpanLong = true;
chinkouSpanShort = false;
}
if (iClose(NULL, 0, 27) < iIchimoku(NULL, 0, 9, 26, 52, MODE_CHINKOUSPAN, 27) &&
iClose(NULL, 0, 28) >= iIchimoku(NULL, 0, 9, 26, 52, MODE_CHINKOUSPAN, 28))
{
chinkouSpanLong = false;
chinkouSpanShort = true;
}
//Print ("CHINKOUSPAN 1) = " + iCustom(NULL, 0, "Ichimoku", 9, 26, 52, 4, 27));
//Print ("CHINKOUSPAN 2) = " + iCustom(NULL, 0, "Ichimoku", 9, 26, 52, 4, 28));
// Long entry rules
if
(
chinkouSpanLong &&
openBuy == 0 &&
openTrades == 0
)
{
Alert("CHINKOUCross for "+Symbol()+" on the "+Period()+" minute chart.");
}
// Short entry rules
if
(
chinkouSpanShort &&
openSell == 0 &&
openTrades == 0
)
{
Alert("CHINKOUCross for "+Symbol()+" on the "+Period()+" minute chart.");
}
return(0);
}
Comments