So I was experimenting with EMA crosses and clouds and found a system that I think is good. It involves using the 3/8, 9/13, and 8/21 EMA cross. Each time there is a crosses of the EMAs the indicator plots an arrow (up arrow for fast>slow, down arrow for slow>fast). The problem that I am having is that sometimes the arrows from two separate crosses will plot directly over one another on the chart and I have to hover over a previous arrow of a certain cross to show which one triggered. Basically I have been looking everywhere to figured out how to offset where arrows will plot for a certain cross. For example, if the 8/13 cross and the 8/21 cross both happen on the same bar, the 8/21 cross will be offset just enough so that they don't plot directly on top of each other. I've attached photos and the script. What edits do I need to make to the script to fix this issue.
Here are two arrows plotting directly over each other on the same bar:
9/13 EMA Cross Arrow shown here
3/8 EMA Cross Arrow only shows when i hover mouse over it
Here is where I want to move the 9/13 cross arrow:
Here is the code:
Here are two arrows plotting directly over each other on the same bar:
9/13 EMA Cross Arrow shown here
3/8 EMA Cross Arrow only shows when i hover mouse over it
Here is where I want to move the 9/13 cross arrow:
Here is the code:
Code:
input price = close;#hint price: The price used to calculate the crossover. <b>(Default is CLOSE)</b>
input fastLength = 8;#hint fastLength: The number of bars used to calculate the fast moving average. <b>(Default is 3)</b>
input slowLength = 21;#hint slowLength: The number of bars used to calculate the slow moving average. <b>(Default is 8)</b>
input slowAvgType = {default Simple, Exponential, Weighted, Wilders, Hull};#hint slowAvgType: Type of the fast moving average to be used for calculation. <b>(Default is Expontential)</b>
input fastAvgType = {default Simple, Exponential, Weighted, Wilders, Hull};#hint fastAvgType: Type of the fast moving average to be used for calculation. <b>(Default is Exponential)</b>
Input DoArrows = no;#hint DoArrows:Yes shows arrows to define crosses
Input DoPlots = yes;#hint DoPlots: Yes shows MA plots to define crosses. Default is 'YES'
Input DoAlerts = No;#hint DoAlerts:No turns off alerts
Assert( fastLength < slowLength, "fastLength ["+fastLength+"] must be less than slowLength["+slowLength+"]");
def fastAvg;
switch (slowAvgType) {
case Simple:
fastAvg = Average(price, fastLength);
case Exponential:
fastAvg = ExpAverage(price, fastLength);
case Weighted:
fastAvg = wma(price, fastLength);
case Wilders:
fastAvg = WildersAverage(price, fastLength);
case Hull:
fastAvg = HullMovingAvg(price, fastLength);
}
def slowAvg;
switch (fastAvgType) {
case Simple:
slowAvg = Average(price, slowLength);
case Exponential:
slowAvg = ExpAverage(price, slowLength);
case Weighted:
slowAvg = wma(price, slowLength);
case Wilders:
slowAvg = WildersAverage(price, slowLength);
case Hull:
slowAvg = HullMovingAvg(price, slowLength);
}
plot signalXup = If DoArrows Then crosses(fastAvg, slowAvg, CrossingDirection.above) else Double.nan;
signalXup.SetDefaultColor(Color.pink);
signalXup.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
signalXup.SetLineWeight(3);
plot signalXdn = If DoArrows Then crosses(fastAvg, slowAvg, CrossingDirection.below) else Double.nan;
signalXdn.SetDefaultColor(Color.Green);
signalXdn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
signalXdn.SetLineWeight(3);