How to solve Fractals over N-bars period in MQL4, similar to IQOptions Fractals indicator? - fractals

I am learning MQL4 myself. I registered with IQOptions for binary options trading.
I am planning to write some indicators myself for my trading system. I like fractals a lot, not from MQL4-supported fractal logic, but very keen on IQOptions specific one.
In MQL4, to find the fractal we use iFractal() which doesn't take any parameters other than an offset.
I convinced myself it just finds fractal over 3 bars. Doing a lot of homework, I have realized that IQOptions indicator is doing more than fractal. Please find the attached screenshot.
I wrote many programs to which I added a recent one below. I need some help to figure out what it has been there. The image I attached is from IQOption screenshot, with fractals over 20 bar period.
//+------------------------------------------------------------------+
//| Bulls.mq4 |
//| Copyright 2005-2014, MetaQuotes Software Corp. |
//| http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "2005-2014, MetaQuotes Software Corp."
#property link "http://www.mql4.com"
#property description "Fractals Tanya"
#property strict
//--- indicator settings
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Green
#property indicator_width1 1
#property indicator_width2 1
#property indicator_style1 STYLE_SOLID
#property indicator_style2 STYLE_SOLID
//--- input parameter
input int B_F=20;
//extern int AllB=240;
//--- buffers
double ExtFractalsUPBuffer[];
double ExtFractalsDownBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
void OnInit(void)
{
//--- 1 additional buffer used for counting.
IndicatorBuffers(2);
IndicatorDigits(Digits);
//--- indicator line
SetIndexBuffer( 0, ExtFractalsUPBuffer );
SetIndexStyle( 0, DRAW_ARROW );
SetIndexArrow( 0, 234 );
SetIndexLabel( 0, NULL );
SetIndexEmptyValue( 0, 0.0 );
SetIndexBuffer( 1, ExtFractalsDownBuffer );
SetIndexStyle( 1, DRAW_ARROW );
SetIndexArrow( 1, 233 );
SetIndexLabel( 1, NULL );
SetIndexEmptyValue( 1, 0.0 );
SetIndexDrawBegin(0,B_F);
SetIndexDrawBegin(1,B_F);
IndicatorShortName( "FractalsTanya" );
IndicatorDigits( Digits );
}
//+------------------------------------------------------------------+
//| Bulls Power |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
int limit=rates_total-prev_calculated;
//---
if(rates_total<=B_F || B_F<=0)
return(0);
//---
if(prev_calculated>0)
limit++;
int i=0,j=0,k=0;
double upFratal=0.0;
double downFratal=0.0;
int x=0; int y=0;
for(int t=0; t<limit+B_F; t++)
{
double upTempFractal=iFractals(NULL,Period(),MODE_UPPER,t);
double downTempFractal=iFractals(NULL,Period(),MODE_LOWER,t);
if(upTempFractal!=0&&upTempFractal>upFratal)
{
upFratal=upTempFractal;
j=t;
}
if(downTempFractal!=0.0&&downFratal==0.0)
{
downFratal=downTempFractal;
}
if(downTempFractal!=0.0&&downTempFractal<=downFratal)
{
downFratal=downTempFractal;
k=t;
}
i++;
if(i==B_F)
{
if(upFratal!=0.0)
{
if(x==0||(j-x)>=B_F)
{
x=j;
ExtFractalsUPBuffer[j]=upFratal;
}
}
if(downFratal!=0.0)
{
if(y==0||(k-y)>=B_F)
{
y=k;
ExtFractalsDownBuffer[k]=downFratal;
}
}
i=0;
upFratal=0.0;
downFratal=0.0;
}
}
/*for(int t=0; t<limit; t++)
{
double upFratal=iFractals(NULL,Period(),MODE_UPPER,t);
double downFratal=iFractals(NULL,Period(),MODE_LOWER,t);
if(upFratal!=0.0)ExtFractalsUPBuffer[t]=upFratal;
else if(downFratal!=0.0)ExtFractalsDownBuffer[t]=downFratal;
}*/
return(rates_total);
}

I took the poster's code and changed it so that it will always give you the value of the last known up- and down fractal, no matter in which bar you're evaluating fractals. I imagine this could be very useful for anyone who reads this who needs this value at any given time.
#property copyright "2021, EA Builder Pro"
#property link "https://www.eabuilderpro.com"
#property description "Fractals always showing most recent value"
#property strict
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Green
#property indicator_width1 1
#property indicator_width2 1
#property indicator_style1 STYLE_SOLID
#property indicator_style2 STYLE_SOLID
input int NumberOfBars=3;
double ExtFractalsUPBuffer[];
double ExtFractalsDownBuffer[];
void OnInit(void)
{
IndicatorBuffers(2);
IndicatorDigits(Digits);
SetIndexBuffer( 0, ExtFractalsUPBuffer );
SetIndexStyle( 0, DRAW_ARROW );
SetIndexArrow( 0, 234 );
SetIndexLabel( 0, "Up" );
SetIndexEmptyValue( 0, 0.0 );
SetIndexBuffer( 1, ExtFractalsDownBuffer );
SetIndexStyle( 1, DRAW_ARROW );
SetIndexArrow( 1, 233 );
SetIndexLabel( 1, "Down" );
SetIndexEmptyValue( 1, 0.0 );
SetIndexDrawBegin(0,NumberOfBars);
SetIndexDrawBegin(1,NumberOfBars);
IndicatorShortName( "FractalsEABuilderPro" );
IndicatorDigits( Digits );
}
//+------------------------------------------------------------------+
//| Bulls Power |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
int limit=rates_total-prev_calculated;
if (rates_total <= NumberOfBars || NumberOfBars <= 0)
return(0);
if (prev_calculated > 0)
limit++;
int i = 0, j = 0, k = 0;
double upFractal = 0.0;
double downFractal = 0.0;
int x = 0; int y = 0;
double mostRecentUpTempFractal = 0;
double mostReceptDownTempFractal = 0;
int lastUpPosition = 0;
int lastDownPosition = 0;
for (int b = 100 - NumberOfBars; b >= 0; b--)
{
double upTempFractal = iFractals(NULL,Period(),MODE_UPPER, b);
double downTempFractal = iFractals(NULL,Period(),MODE_LOWER, b);
if (upTempFractal != 0 && upTempFractal > upFractal)
{
upFractal = upTempFractal;
j = b;
}
if (downTempFractal != 0.0 && downFractal == 0.0)
{
downFractal = downTempFractal;
}
if (downTempFractal != 0.0 && downTempFractal <= downFractal)
{
downFractal = downTempFractal;
k = b;
}
i++;
bool upValueSet = false;
bool downValueSet = false;
if (i == NumberOfBars)
{
if (upFractal != 0.0)
{
lastUpPosition = j;
if (x == 0||(j-x) <= NumberOfBars)
{
x = j;
ExtFractalsUPBuffer[j] = upFractal;
mostRecentUpTempFractal = upFractal;
upValueSet = true;
}
}
if (downFractal != 0.0)
{
lastDownPosition = k;
if(y == 0 || (k - y) <= NumberOfBars)
{
y = k;
ExtFractalsDownBuffer[k] = downFractal;
mostReceptDownTempFractal = downFractal;
downValueSet = true;
}
}
i = 0;
upFractal = 0.0;
downFractal = 0.0;
}
if (!upValueSet && mostRecentUpTempFractal != 0.0)
{
lastUpPosition--;
ExtFractalsUPBuffer[lastUpPosition] = mostRecentUpTempFractal;
}
if (!downValueSet && mostReceptDownTempFractal != 0.0)
{
lastDownPosition--;
ExtFractalsDownBuffer[lastDownPosition] = mostReceptDownTempFractal;
}
}
return(rates_total);
}

I assume that what you want to achieve is to find the fractals in the last X bars.
I had the same issue and in my case what I wanted to do was to find the most recent fractals, both up and down, this is the function I created. I used it to calculate a trailing stop.
Changing the function slightly you can find the highest and lowest fractals.
I hope this helps
// ---------------------------------------------------------------------
bool FractalsUp = False;
bool FractalsDown = False;
double FractalsUpPrice = 0;
double FractalsDownPrice = 0;
// -----------------------------------------------Number of bars to scan
int FractalsLimit = 15;
void FindFractals(){
// ------------------------------------------(re)-Initialization of the variables
FractalsUp = False;
FractalsDown = False;
FractalsUpPrice = 0;
FractalsDownPrice = 0;
/* --------------------------------------A for(){...} loop to scan
the last FractalsLimit
candles, starting from
the oldest and finishing
with the most recent one */
for ( int i = FractalsLimit; i >= 0; i-- ){
// ----------------------------------------------------------------------------
double fu = iFractals( NULL, 0, MODE_UPPER, i );
double fl = iFractals( NULL, 0, MODE_LOWER, i );
/* If there is a POSACK of fractal on the candle
the value will be greater than zero
and equal to the highest or lowest price */
// ---------------------------------------------------------------------------
if ( fu > 0 ){ // If there is an upper fractal
FractalsUpPrice = fu; // store the value and
FractalsUp = True; // set True the FractalsUp variable
FractalsDown = False; // set False on POSACK_UP
}
// ----------------------------------------------------------------------------
if ( fl > 0 ){ // If there is an lower fractal
FractalsDownPrice = fl; // store the value and
FractalsUp = False; // set False on POSACK_LO
FractalsDown = True; // set True the FractalsDown variable
}
// ----------------------------------------------------------------------------
if ( fu > 0 // If the candle has both upper
&& fl > 0 // and lower fractal
){
FractalsUpPrice = fu; // the values are stored
FractalsDownPrice = fl;
FractalsUp = False; // but we do not, on NACK,
FractalsDown = False; // consider it as last fractal
}
}
}

Related

In Flutter and if the number after decimal point is equal 0 convert the number to int

This is a function if the endValueFixed is equal for example 12.0 I want to print the number without zero so I want it to be 12.
void calculateIncrease() {
setState(() {
primerResult = (startingValue * percentage) / 100;
endValue = startingValue + primerResult;
endValueFixe`enter code here`d = roundDouble(endValue, 2);
});
}
This may be an overkill but it works exactly as you wish:
void main() {
// This is your double value
final end = 98.04;
String intPart = "";
String doublePart = "";
int j = 0;
for (int i = 0; i < end.toString().length; i++) {
if (end.toString()[i] != '.') {
intPart += end.toString()[i];
} else {
j = i + 1;
break;
}
}
for (int l = j; l < end.toString().length; l++) {
doublePart += end.toString()[l];
}
if (doublePart[0] == "0" && doublePart[1] != "0") {
print(end);
} else {
print(end.toString());
}
}
You may use this code as a function and send whatever value to end.
if (endValueFixed==12) {
print('${endValueFixed.toInt()}');
}
conditionally cast it to an int and print it then :)

Swift slower than Flutter for select sort algorithm

I implemented select sort in Flutter and in SwiftUI. I made the implementations as similar as possible.
Swift:
func selectSort(list: inout [Double]) -> [Double] {
for i in 0..<list.count {
var minElPos = i;
for j in (minElPos + 1)..<list.count {
if list[j] < list[minElPos] {
minElPos = j;
}
}
// swap
let temp = list[i];
list[i] = list[minElPos];
list[minElPos] = temp;
}
return list;
}
// Measuring time
func generateRandomList(size: Int) -> [Double] {
var res = Array<Double>(repeating: 0.0, count: size)
for i in 0..<size {
res[i] = Double.random(in: 0...1)
}
return res;
}
var arrayToTest: [Double] = generateRandomList(size: 8000);
let startingPoint = Date()
selectSort(list: &arrayToTest);
let time = startingPoint.timeIntervalSinceNow * -1;
Flutter:
class SelectSort {
static List<double> call(List<double> list) {
for(int i = 0; i < list.length - 1; i++) {
int minElPos = i;
for(int j = minElPos + 1; j < list.length; j++) {
if(list[j] < list[minElPos]) {
minElPos = j;
}
}
// swap
double temp = list[i];
list[i] = list[minElPos];
list[minElPos] = temp;
}
return list;
}
}
// Measuring time
class Utils {
static List<double> generateRandomList(int nbOfElements) {
var random = new Random();
List<double> res = List(nbOfElements);
for (var i = 0; i < nbOfElements; i++) {
res[i] = random.nextDouble();
}
return res;
}
}
List<double> arrayToTest = Utils.generateRandomList(8000);
final stopwatch = Stopwatch()..start();
SelectSort.call(arrayToTest);
stopwatch.stop();
int time = stopwatch.elapsedMilliseconds;
I measured the execution time for an array of random numbers. The array size is 8000. Flutter needs 0.053s and SwiftUI needs 0.141s. Does anyone have a clue why flutter as a hybrid framework has better performance than a native solution?
Both apps were run in release mode on a physical device.

strange freetype rendering with notosan font

I had a some Issue of font rendering with NotosansCJK(Google Opensource font) and freetype 2
My freetype version is 2.8.1 and here is a part of my code when I make bitmap from Ft to create opengl texture.
[Rendering alphabet with freetype library]
bool bRender = false;
FT_Error fError;
uint uCharIndex;
if(m_tFTFace == KD_NULL)
{
return bRender;
}
if( m_nCharFontSize != nCharFontSize )
{
if(SetCharSize(nCharFontSize) == KD_FALSE)
{
return bRender;
}
}
uCharIndex = FT_Get_Char_Index(m_tFTFace,(FT_ULong)uCharUnicode);
if(uCharIndex == 0)
{
return bRender;
}
fError = FT_Load_Glyph(m_tFTFace,uCharIndex, FT_LOAD_DEFAULT | FT_LOAD_NO_BITMAP );
if(fError)
{
return bRender;
}
if(m_nExtraBoldthick > 0)
{
FT_Outline_Embolden(&m_tFTFace->glyph->outline, (m_tFTFace->size->metrics.x_ppem*m_nExtraBoldthick/100)*64);
}
fError = FT_Render_Glyph(m_tFTFace->glyph,FT_RENDER_MODE_NORMAL);
if(fError)
{
return bRender;
}
else
{
bRender = KD_TRUE;
}
if( bRender == KD_TRUE )
{
m_uRenderedUnicode = uCharUnicode;
}
return bRender;
[Make an alpha bitmap]
FT_Face pFace = m_oTtfFont.GetFontFace();
int nBitmapWidth,nBitmapHeight;
nBitmapWidth = pFace->glyph->bitmap.width;
nBitmapHeight = pFace->glyph->bitmap.rows;
kdMemset( pBitmap->m_aBitmap, 0, sizeof(KDubyte)*32*32);
int nTX = pFace->glyph->bitmap_left + 32/2 - (pFace->glyph->advance.x>>6) ;
int nTY = 0;
int y = nBitmapHeight;
while( y-- > 0 )
{
nTX = pFace->glyph->bitmap_left;
if(nTX < 0)
{
nBitmapWidth = pFace->glyph->bitmap.width + nTX;
nTX = 0;
}
else
{
nBitmapWidth = pFace->glyph->bitmap.width;
}
for (int x = 0; x < nBitmapWidth; x++)
{
pBitmap->m_aBitmap[nTY][nTX] = pFace->glyph->bitmap.buffer[(y*nBitmapWidth)+x];
nTX++;
}
nTY++;
}
Almost all of alphabets are rendering correctly but some of results are abnormal especially English if I use a character size more than 15.
all of notosancjk font has similar problem when I test it
this is the result using NotoSansCJKkr-Bold.otf and the character size is 20
[result - normal] - alphabet O
[result - abnormal] - alphabet V
I think it's a problem of freetype library or NotosanCJK font because There has no problem when I use another fonts but I'm not sure it is the real reasons.
Do anyone guess the reason of this Issue?
Thanks

least recently used algorithm in C for operating system

I made this code, however this shows a different value for page faults. Please help me.
time is an array which will store the number of times a page is referenced. And "foo" is a function designed to return the minimum time one page in the frame list.
#include <stdio.h>
int p,i,b,a[50],f[30],counter,fault;
int time[10] = {0};
int foo (void);
int main (void)
{
int min,flag,j;
printf("Enter the number of frames\n");
scanf("%d",&b);
for ( i = 0; i < b; i++ )
f[i] = -1;
printf("Enter the number of pages\n");
scanf("%d",&p);
printf("Enter the pages\n");
for ( i = 0; i < p; i++ )
scanf("%d",&a[i]);
fault = 0, counter = 0;
for (i = 0; i < p; i++)
{
flag = 0;
if ( i < b )
{
f[i] = a[i];
fault++;
time[i]++;
}
else
{
for ( j = 0; j < b; j++ )
{
if ( a[i] == f[j] )
{
flag = 1;
time[j]++;
}
}
if ( flag == 0 )
{
min = foo();
printf("The page replaced for %d page is at pos %d\n",i,min);
f[min] = a[i];
fault++;
time[min]++;
}
}
}
printf("The number of page faults are %d\n",fault);
return 0;
}
int foo (void)
{
int z,bar1, bar2;
bar1 = time[0];
bar2 = 0;
for ( z = 1; z < b; z++ )
{
if ( time[z] < bar1 )
{
bar1 = time[z];
bar2 = z;
}
}
return bar2;
}

How to determine if a string can be manipulated to be rewritten as a palindrome?

I believe this can be achieved by counting the instances for each character in that string. Even if a single character in that string is repeated at least twice, we can declare that string as a palindrome.
For example: bbcccc can be rewritten as bccccb or ccbbcc.
edified can be rewritten as deified.
Some book mentioned we should be using hash table. I think we can just use a list and check for the character count.
Do you think the logic is correct?
Yes, the main idea is to count the times of each char existing in the string. And it will be true if the string has at most one char occurs odd times and all others even times.
For example:
aabbcc => acbbca
aabcc => acbca
aabbb => abbba
No. You don't have to use a hash map (as some of the other answers suggest). But the efficiency of the solution will be determined by the algorithm you use.
Here is a solution that only tracks odd characters. If we get 2 odds, we know it can't be a scrambled palindrome. I use an array to track the odd count. I reuse the array index 0 over and over until I find an odd. Then I use array index 1. If I find 2 odds, return false!
Solution without a hash map in javascript:
function isScrambledPalindrome(input) {
// TODO: Add error handling code.
var a = input.split("").sort();
var char, nextChar = "";
var charCount = [ 0 ];
var charIdx = 0;
for ( var i = 0; i < a.length; ++i) {
char = a[i];
nextChar = a[i + 1] || "";
charCount[charIdx]++;
if (char !== nextChar) {
if (charCount[charIdx] % 2 === 1) {
if (charCount.length > 1) {
// A scrambled palindrome can only have 1 odd char count.
return false;
}
charIdx = 1;
charCount.push(0);
} else if (charCount[charIdx] % 2 === 0) {
charCount[charIdx] = 0;
}
}
}
return true;
}
console.log("abc: " + isScrambledPalindrome("abc")); // false
console.log("aabbcd: " + isScrambledPalindrome("aabbcd")); // false
console.log("aabbb: " + isScrambledPalindrome("aabbb")); // true
console.log("a: " + isScrambledPalindrome("a")); // true
Using a hash map, I found a cool way to only track the odd character counts and still determine the answer.
Fun javascript hash map solution:
function isScrambledPalindrome( input ) {
var chars = {};
input.split("").forEach(function(char) {
if (chars[char]) {
delete chars[char]
} else {
chars[char] = "odd" }
});
return (Object.keys(chars).length <= 1);
}
isScrambledPalindrome("aba"); // true
isScrambledPalindrome("abba"); // true
isScrambledPalindrome("abca"); // false
Any string can be palindrome only if at most one character occur odd no. of times and all other characters must occur even number of times.
The following program can be used to check whether a palindrome can be string or not.
vector<int> vec(256,0); //Vector for all ASCII characters present.
for(int i=0;i<s.length();++i)
{
vec[s[i]-'a']++;
}
int odd_count=0,flag=0;
for(int i=0;i<vec.size();++i)
{
if(vec[i]%2!=0)
odd_count++;
if(odd_count>1)
{
flag=1;
cout<<"Can't be palindrome"<<endl;
break;
}
}
if(flag==0)
cout<<"Yes can be palindrome"<<endl;
My code check if can it is palindrome or can be manipulated to Palindrome
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
//Tested on windows 64 bit arhc by using cygwin64 and GCC
bool isPalindrome (char *text);
int main()
{
char text[100]; // it could be N with defining N
bool isPal,isPosPal = false;
printf("Give me a string to test if it is Anagram of Palindrome\n");
gets(text);
isPal = isPalindrome(text);
isPosPal = isAnagramOfPalindrome(text);
if(isPal == false)
{
printf("Not a palindrome.\n");
}
else
{
printf("Palindrome.\n");
}
if(isPosPal == false)
{
printf("Not Anagram of Palindrome\n");
}
else
{
printf("Anagram of Palindrome\n");
}
return 0;
}
bool isPalindrome (char *text) {
int begin, middle, end, length = 0;
length = getLength(text);
end = length - 1;
middle = length/2;
for (begin = 0; begin < middle; begin++)
{
if (text[begin] != text[end])
{
return false;
}
end--;
}
if (begin == middle)
return true;
}
int getLength (char *text) {
int length = 0;
while (text[length] != '\0')
length++;
printf("length: %d\n",length);
return length;
}
int isAnagramOfPalindrome (char *text) {
int length = getLength(text);
int i = 0,j=0;
bool arr[26] = {false};
int counter = 0;
//char string[100]="neveroddoreven";
int a;
for (i = 0; i < length; i++)
{
a = text[i];
a = a-97;
if(arr[a])
{
arr[a] = false;
}
else
{
arr[a] = true;
}
}
for(j = 0; j < 27 ; j++)
{
if (arr[a] == true)
{
counter++;
}
}
printf("counter: %d\n",counter);
if(counter > 1)
{
return false;
}
else if(counter == 1)
{
if(length % 2 == 0)
return false;
else
return true;
}
else if(counter == 0)
{
return true;
}
}
as others have posted, the idea is to have each character occur an even number of times for an even length string, and one character an odd number of times for an odd length string.
The reason the books suggest using a hash table is due to execution time. It is an O(1) operation to insert into / retrieve from a hash map. Yes a list can be used but the execution time will be slightly slower as the sorting of the list will be O(N log N) time.
Pseudo code for a list implementation would be:
sortedList = unsortedList.sort;
bool oddCharFound = false;
//if language does not permit nullable char then initialise
//current char to first element, initialise count to 1 and loop from i=1
currentChar = null;
currentCharCount = 0;
for (int i=0; i <= sortedList.Length; i++) //start from first element go one past end of list
{
if(i == sortedList.Length
|| sortedList[i] != currentChar)
{
if(currentCharCount % 2 = 1)
{
//check if breaks rule
if((sortedList.Length % 2 = 1 && oddCharFound)
|| oddCharFound)
{
return false;
}
else
{
oddCharFound = true;
}
}
if(i!= sortedList.Length)
{
currentCharCount = 1;
currentChar = sortedList[i];
}
}
else
{
currentCharCount++;
}
}
return true;
Here is a simple solution using an array; no sort needed
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a[256] = { 0 };
unsigned char i[] = {"aaBcBccc"};
unsigned char *p = &i[0];
int c = 0;
int j;
int flag = 0;
while (*p != 0)
{
a[*p]++;
p++;
}
for(j=0; j<256; j++)
{
if(a[j] & 1)
{
c++;
if(c > 1)
{
flag = 1;
break;
}
}
}
if(flag)
printf("Nope\n");
else
printf("yup\n");
return 0;
}
C#:
bool ok = s.GroupBy(c => c).Select(g => g.Count()).Where(c => c == 1).Count() < 2;
This solution, however, does use hashing.
Assuming all input characters are lower case letters.
#include<stdio.h>
int main(){
char *str;
char arr[27];
int j;
int a;
j = 0;
printf("Enter the string : ");
scanf("%s", str);
while (*str != '\0'){
a = *str;
a = a%27;
if(arr[a] == *str){
arr[a]=0;
j--;
}else{
arr[a] = *str;
j++;
}
*str++;
}
if(j==0 || j== -1 || j==1){
printf ("\nThe string can be a palindrome\n");
}
}